<template>
    <div class="cont mb-4">
        <CustomQuery @submit="changeQuery" :form-columns="queryList"></CustomQuery>
    </div>
    <div class="cont">
        <CustomTable selection :columns="columns" :data-source="data">
            <template #column-action="{ record }">
                <a-switch v-model:checked="record.checked" />
            </template>
        </CustomTable>
    </div>
</template>

<script setup lang="ts">
import CustomTable from '@/components/customTable/CustomTable.vue';
import CustomQuery from '@/components/customQuery/CustomQuery.vue';
import { CustomQueryColumns, CustomQueryValue } from '@/components/customQuery/types';
import { CustomTableColumns, CUstomTableData } from '@/components/customTable/types';

const queryList = reactive<CustomQueryColumns[]>([
    { label: '开户行', key: 'openingBank', type: 'input' },
    { label: '银行卡号', key: 'bankCardNumber', type: 'input' },
    { label: '真实姓名', key: 'realName', type: 'input' },
    { label: '提现编号', key: 'withdrawalNumber', type: 'input' },
    {
        label: '状态', key: 'state', type: 'select', options: [
            { label: '状态: 全部', value: '1' },
            { label: '状态: 启用', value: '2' },
            { label: '状态: 禁用', value: '3' },
        ],value:'1'
    }
])

const changeQuery = (queryState: CustomQueryValue) => {
    alert('查询结果为' + JSON.stringify(queryState))
}

const data = ref<CUstomTableData[]>([])
const columns = reactive<CustomTableColumns[]>([
    {
        title: "编号",
        dataIndex: "code",
        key: "code",
    },
    {
        title: "提现用户",
        dataIndex: "withdrawingUsers",
        key: "withdrawingUsers",
    },
    {
        title: "用户",
        dataIndex: "user",
        key: "user",
    },
    {
        title: "提现金额",
        dataIndex: "withdrawalAmount",
        key: "withdrawalAmount",
    },
    {
        title: "提现账户",
        dataIndex: "withdrawalAccount",
        key: "withdrawalAccount",
    },
    {
        title: "状态",
        dataIndex: "state",
        key: "state",
    },
    {
        title: "时间",
        dataIndex: "time",
        key: "time",
    },
    {
        flag: 'ACTION'
    },
]);


onMounted(() => {
    for (let i = 0; i < 100; i++) {
        data.value.push(
            {name:'标签组名称',label:'这是标签',time: '2024-08-16'}
        )
    }
})
</script>

<style scoped></style>